<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//  关联数组--->Json格式
$season=array('one'=>'spring','two'=>'summer','three'=>'autumn','four'=>'winter');
var_dump($season);
echo "<hr/>";
echo json_encode($season);
echo "<hr/>";

//  索引数组--->Json格式
$fruit=array('banana','apple','mango','orange');
var_dump($fruit);
echo "<hr/>";
echo json_encode($fruit);
echo "<hr/>";

//索引、关联数组--->Json格式
$color=array('red','green','pink'=>'pink','purple');
var_dump($color);
echo json_encode($color);
echo "<hr/>";

//二维数组--->Json格式
$s1=array("name"=>"Felix","addr"=>'America');
$s2=array("name"=>"Paul","addr"=>'Russia');
$student=array($s1,$s2);
var_dump($student);
echo json_encode($student);
echo "<hr/>";


$fruit1=array('north'=>'pear','shandong'=>'apple','hainan'=>'banana');
$json_fruit=json_encode($fruit1);
 var_dump($json_fruit);
 echo '<hr/>';
 var_dump(json_decode($json_fruit),true);
